//
//  LTTicketListViewController.m
//  LocalTravel
//  景点票价列表
//  Created by zheng ji on 14-3-20.
//  Copyright (c) 2014年 jxw. All rights reserved.
//

#import "LTTicketListViewController.h"

@interface LTTicketListViewController ()
{
    NSString* _sceneryId;
    NSMutableArray* _priceArray;
}
@end

@implementation LTTicketListViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
     
    [self.tableView registerClass:[TicketTableCell class] forCellReuseIdentifier:@"TicketTableCell"];
    [self loadTicketData];
}
-(void)loadTicketData{
    if(self.dictScenery==nil)return ;
    _sceneryId=[self.dictScenery objectForKey:@"sceneryId"];
    NSString* xmlData=[LocalTravelRequest getSceneryPrice:_sceneryId showDetail:1 useCache:0];
    SceneryPriceParse* parse=[[SceneryPriceParse alloc]initWithXmlData:xmlData];
    _priceArray=[parse getScenaryPriceList];
    parse=nil;
    xmlData=nil;
    
   // NSLog(@"%@",xmlData);
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 84;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
       return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(_priceArray !=nil) return _priceArray.count;

    return 0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TicketTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TicketTableCell" forIndexPath:indexPath];
    
    if(_priceArray !=nil && _priceArray.count>indexPath.row){
        NSDictionary* dict=[_priceArray objectAtIndex:indexPath.row];
        
        cell.lblPolicyName.text=[dict objectForKey:@"policyName"];
        
        //cell.lblPrice.isWithStrikeThrough=YES;
        cell.lblPrice.text=[dict objectForKey:@"price"];
        cell.lblTCPrice.textColor=[UIColor redColor];
        cell.lblTCPrice.text=[dict objectForKey:@"tcPrice"];
    }
    
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
